import { _decorator, Component, director, Label, Node } from "cc";
import GameData from "../GameData";
const { ccclass, property } = _decorator;

@ccclass("GameOverUI")
export class GameOverUI extends Component {
  @property(Label)
  public currentScoreLabel: Label = null;

  @property(Label)
  public highScoreLabel: Label = null;

  @property(Node)
  public newSprite: Node = null;

  @property(Node)
  public medalsSprite0: Node = null;

  @property(Node)
  public medalsSprite1: Node = null;

  @property(Node)
  public medalsSprite2: Node = null;

  @property(Node)
  public medalsSprite3: Node = null;

  protected start() {}

  protected update(deltaTime: number) {}

  public show(score: number, hightScore: number) {
    this.node.active = true;
    this.currentScoreLabel.string = `${score}`;
    this.highScoreLabel.string = `${hightScore}`;

    if (score > hightScore) {
      this.newSprite.active = true;
    } else {
      this.newSprite.active = false;
    }
    // 0-9
    // 10-19
    // 20-29
    // 30
  }

  public hide() {
    this.node.active = false;
  }

  public replay() {
    director.loadScene("Game");
  }
}
